<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>太极摆钟</title>
  </head>
  <style>
    .clock-box {
      width: 100px;
      transform: rotate(30deg);
      transform-origin: 50px 0;
      animation-name: swing;
      animation-duration: 2s;
      animation-iteration-count: infinite;
      margin: -10px auto 0 auto;
    }
    .point {
      width: 20px;
      height: 20px;
      background-color: #000;
      border-radius: 100%;
      margin: 30px auto 0 auto;
    }
    .line {
      width: 2px;
      height: 360px;
      background-color: #000;
      margin: auto;
    }
    .circle {
      width: 100px;
      height: 100px;
      border: 2px solid #000;
      border-radius: 100%;
      margin: auto;
      box-shadow: 0 0 10px 0px #1d1c1c;
      overflow: hidden;
      position: relative;
      animation: circle 4s;
      animation-name: circle;
      animation-duration: 8s;
      animation-iteration-count: infinite;
      animation-timing-function: linear;
    }
    .black {
      width: 52px;
      height: 100px;
      background-color: #000;
      position: absolute;
      right: 0;
      z-index: 10;
    }
    .white-circle {
      width: 50px;
      height: 50px;
      border-radius: 100%;
      background-color: #fff;
      position: absolute;
      margin: auto;
      left: 0;
      right: 0;
      z-index: 11;
    }
    .little-white-circle {
      width: 14px;
      height: 14px;
      border-radius: 100%;
      background-color: #fff;
      position: absolute;
      margin: auto;
      left: 0;
      right: 0;
      bottom: 20px;
      z-index: 12;
    }
    .black-circle {
      width: 50px;
      height: 50px;
      border-radius: 100%;
      background-color: #000;
      position: absolute;
      margin: auto;
      left: 0;
      right: 0;
      top: 50px;
      z-index: 11;
    }
    .little-black-circle {
      width: 14px;
      height: 14px;
      border-radius: 100%;
      background-color: #000;
      position: absolute;
      margin: auto;
      left: 0;
      right: 0;
      top: 20px;
      z-index: 12;
    }
    .second {
      text-align: center;
      font-size: 48px;
      font-weight: bold;
      margin-top: 20px;
    }

    @keyframes swing {
      0% {
        transform: rotate(30deg);
      }
      50% {
        transform: rotate(-30deg);
      }
      100% {
        transform: rotate(30deg);
      }
    }
    @keyframes circle {
      0% {
        transform: rotate(0deg);
      }
      100% {
        transform: rotate(360deg);
      }
    }
  </style>
  <body>
    <div class="point"></div>
    <div class="clock-box">
      <div class="line"></div>
      <div class="circle">
        <div class="black"></div>
        <div class="white-circle"></div>
        <div class="black-circle"></div>
        <div class="little-white-circle"></div>
        <div class="little-black-circle"></div>
      </div>
    </div>
    <div class="second"></div>
  </body>
  <script>
    const secondBox = document.querySelector(".second");

    function setTime() {
      const date = new Date();
      const h = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
      const m =
        date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
      const s =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      secondBox.innerHTML = h + ":" + m + ":" + s;
    }

    setInterval(() => {
      setTime();
    }, 1000);

    setTime();
  </script>
</html>
